package com.JavaBasic;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class TimerDemo {
	public static void main(String[] args) {
		Timer tm = new Timer();
		// 当前时间开始执行定时器，没1秒循环一次
		tm.schedule(new MyTimer(), new Date(),1000);
	}
}

class MyTimer extends TimerTask {
	private int number;
	
	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	@Override
	public void run() {
		number++;
		System.out.println(number);
	}
}
